<template>
    <div class="main">
        <view class="search dispaly-just-between">
            <view class="ipt">
                <tn-search-box :search-button="false" :border="false" v-model="searchValue"
                    @search="navTo(`/subPackage/index/searchResult?searchValue=${searchValue}`)"
                    placeholder="搜索职位/公司/内容" />
            </view>
            <view class="text" @click="navTo(`/subPackage/index/searchResult?searchValue=${searchValue}`)">搜索</view>
        </view>
        <view class="search-more">
            <view class="item">
                <view class="title dispaly-just-between">
                    <view class="text">搜索记录</view>
                    <view class="icon" @click="deleteHistory">
                        <image src="/static/icon/del.png" />
                    </view>
                </view>
                <view class="dispaly-between">
                    <view class="desc">
                        <view class="over-1 desc-item dispaly-align-center" v-for="item in number" :key="item"
                            @click="navTo(`/subPackage/index/searchResult?searchValue=${'重庆'}`)">
                            重庆重庆重庆重庆重庆
                        </view>
                    </view>
                    <view class="z-k" @click="showSearchHistory">
                        <image src="/static/icon/down.png" />
                    </view>
                </view>
            </view>

            <view class="item">
                <view class="title dispaly-just-between">
                    <view class="text">搜索发现</view>
                    <view class="icon dispaly-center ">
                        <image src="/static/icon/ref.png" />
                        <view class="h">换一换</view>
                    </view>
                </view>
                <view class="dispaly-between">
                    <view class="desc">
                        <view class="over-1 desc-item dispaly-align-center" v-for="item in number" :key="item"
                            @click="navTo(`/subPackage/index/searchResult?searchValue=${'北京'}`)">
                            重庆重庆重庆重庆重庆
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </div>
</template>

<script setup lang="ts">
import { navTo } from '@/utils/util'
import TnSearchBox from '@tuniao/tnui-vue3-uniapp/components/search-box/src/search-box.vue'
import { ref } from 'vue';

const number = ref<number>(3)

// 搜索
const searchValue = ref<string>('')

// 搜索跳转
const searchSkipPage = () => {
    uni.navigateTo({
        url: '/subPa'
    })
}

// 删除历史记录
const deleteHistory = () => {
    uni.showModal({
        title: '提示',
        content: '是否删除历史记录',
        success: function (res) {
            if (res.confirm) {
                console.log('用户点击确定');
            } else if (res.cancel) {
                console.log('用户点击取消');
            }
        }
    });
}

// 展开搜索历史记录
const showSearchHistory = () => {
    if (number.value == 3) number.value = 5
    else number.value = 3
}
</script>

<style>
page {
    background-color: #fff;
}
</style>

<style lang="scss" scoped>
:deep(.tn-search-box) {
    background-color: #f6f6f6 !important;
}

.main {
    padding: 30rpx;
}

.search {
    .ipt {
        flex: 5;
    }

    .text {
        margin-left: 21rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 28rpx;
        flex: 0.5;
        color: #008298;
    }
}

.search-more {
    .item {
        margin-top: 20rpx;

        .title {
            .text {
                font-family: PingFang SC, PingFang SC;
                font-weight: 800;
                font-size: 34rpx;
                color: #000000;
            }

            .icon {
                .h {
                    margin-left: 3rpx;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 400;
                    font-size: 22rpx;
                    color: #B8B8B8;
                }

                image {
                    width: 25rpx;
                    height: 25rpx;
                }
            }
        }
    }

    .z-k {
        margin-top: 20rpx;

        image {
            width: 27rpx;
            height: 17rpx;
        }
    }

    .desc {
        display: flex;
        flex-wrap: wrap;
        align-items: center;

        .desc-item {
            max-width: 174rpx;
            min-width: 174rpx;
            padding: 0 20rpx;
            margin: 20rpx;
            height: 62rpx;
            text-align: center;
            line-height: 62rpx;
            background: #F5F5F5;
            border-radius: 15rpx;
            font-family: PingFang SC, PingFang SC;
            font-weight: 400;
            font-size: 24rpx;
            color: #000000;
        }
    }
}
</style>